<template>
	<view class="content">
		<view v-html="detail"></view>
		<button @click="toLogin" class="btn" type="primary">确定参加</button>
		<login ref="login"></login>
	</view>
</template>

<script>
	import login from '../components/login/login.vue'
	export default {
		data() {
			return {
				detail: "",
				linkUrl:"",
				urlObj:{},
				b:"",
				channelNo:""
			}
		},
		components: {
			login
		},
		onLoad(params) {
			this.b = params.b
			this.channelNo = params.channelNo
			console.log(params)
			// if(window.location.hostname=='h5.shunxin.cn'){
			// 	this.urlObj = {
			// 		api_one:'https://bu-api.shunxin.cn',
			// 		api_two:'https://api.shunxin.cn'
			// 	}
			// }else{
			// 	this.urlObj = {
			// 		api_one:'https://bu-api-test.shunxin.cn',
			// 		api_two:'https://api-test.shunxin.cn'
			// 	}
			// }
			if(window.location.hostname=='h5.eok.com.cn'){
				this.urlObj = {
					api_one:'https://bu-api.eok.com.cn',
					api_two:'https://api.eok.com.cn'
				}
			}else{
				this.urlObj = {
					api_one:'https://bu-api-test.eok.com.cn',
					api_two:'https://api-test.eok.com.cn'
				}
			}
			uni.request({
				url: `${this.urlObj.api_one}/marketing-service/channelStudioConfiguration/getByTag?tag=2`,
				method: 'GET',
				success: (res) => {
					let content = res.data.data[0].content
					if (content) {
						content = content.replace(
							/(\<img|\<video|\<iframe|\<\/iframe>)/gi,
							function($0, $1) {
								return {
									"<img": '<img style="width:100%;height:auto;display:block;" ',
									"<video": '<video style="max-width:100%;height:auto;" ',
									"<iframe": '<video style="max-width:100%;outline:none;" controls="controls"',
									"</iframe>": "</video>"
								} [$1];
							});
					}
					this.detail = content
					this.linkUrl = res.data.data[0].copywriting
				}
			})
		},
		methods: {
			toLogin() {
				this.$refs.login.open(this.linkUrl,this.urlObj,this.b,this.channelNo)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: 150rpx;

		.img {
			width: 100%;
		}

		.btn {
			position: fixed;
			bottom: 32rpx;
			left: 32rpx;
			width: calc(100% - 64rpx);
			margin-top: 100rpx;
			font-size: 28rpx;
			background: #5677fc;
			color: #fff;
			height: 90rpx;
			line-height: 90rpx;
			border-radius: 50rpx;
			box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
		}
	}
</style>